package com.qfedu.gateway.server.config;

import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import reactor.core.publisher.Mono;

@Configuration
public class AppConfig {


    @Bean
    public KeyResolver keyResolver() {
        //http://localhost:9999/order/query?user=1
        //使⽤请求中的user参数的值作为令牌桶的key
        //return exchange ->Mono.just(exchange.getRequest().getQueryParams().getFirst("user"));
        return exchange -> Mono.just(exchange.getRequest().getURI().getPath());
    }
}
